/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package pruebas;

import java.util.Scanner;

/**
 *
 * @author ddpc
 */
public class sumarray {
    Scanner teclado;
    int [] a;
    sumarray(){
        teclado= new Scanner(System.in);
        System.out.println("Cuantos valores insertaras:");
        int x = teclado.nextInt();
        a = new int[x];
        for (int i = 0; i < a.length; i++) {
            System.out.println("Inserte valor "+i+" :");
            a[i]=teclado.nextInt();
        }
    }
    public void sumar(){
        int suma=0;
        for (int i = 0; i < a.length; i++) {
            suma = suma+a[i];
        }
        System.out.println("la suma de los valores es: "+suma);
    }
    public static void main(String[] args) {
        sumarray p = new sumarray();
        p.sumar();
    }
}
